TimerInt
 
Component TimerInt
Periodic interrupt
Component Level: High
Typical Usage:
(Examples of a typical usage of the component in user code. For more information please see the page Component Code Typical Usage.)

Required component name is "TI1".
There are the following two typical usage modes:

(1)
The easiest usage of the component is a simple periodic event generator. The event handler "TI1_OnInterrupt" is generated with a selected period. Event handler executes as shown in the following example (no method is used):

 EVENTS.C

int i = 0;
void TI1_OnInterrupt(void)
{
  ++i;
}
Note: In this case it is recommended to turn off all the methods of the component.

(2)
Advanced methods of the component allows to change period of the event in runtime. It is possible to select a period from the predefined list using SetPeriodMode method or to set a value from the interval using SetPeriod and SetFreq methods (please refer to Timing dialog box). It is also possible to change the event period in the event handler.
In the following example the event period is switched after each 255-th invocation of the event handler. The mode is changed sequentially from three predefined values.

 EVENTS.C

int rpt_cntr = 255, mode = 0;

void TI1_OnInterrupt(void)
{

  if( --rpt_cntr==0 ) {  // If the event was generated 255times
    if( ++mode==3 ) mode = 0; // Select next mode of the period
    TI1_SetPeriodMode( mode );// Set new period mode
    rpt_cntr = 255; // Set repeat counter
  }
}